import Vue from 'vue';
import App from './App.vue';
import './plugins/element.js';
import router from './router/index';
import store from './store';
import axios from 'axios';
import Contextmenu from 'vue-contextmenujs'

import './assets/css/common/common.less';
import './assets/css/common/loading.less';
import '../src/assets/css/common/reset.less';
import "../src/assets/css/bootstrap.min.css";

import Editor from 'vue2-ace-editor';
Vue.component('editor', Editor);
Vue.use(Contextmenu);

/* eslint-disable */
// 获取服务端动态配置地址方式
function getServerConfig() {
    return new Promise((resolve, reject) => {
        axios
            .get('/serverConfig.json')
            .then((result) => {
                let config = result.data;
                // store.commit("SET_LOGINLOGO", config.loginLogoPath);
                // store.commit("SET_HOMELOGO", config.homeLogoPath);
                store.commit('SET_LOGINTITLE', config.loginTitle);
                // store.commit("SET_HOMETITLE", config.homeTitle);
                axios.defaults.baseURL = config.VUE_APP_API;
                resolve();
            })
            .catch((error) => {
                axios.defaults.baseURL = process.env.VUE_APP_API;
                reject();
            });
    });
}
// 解决路由报错
import VueRouter from 'vue-router';
const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return routerPush.call(this, location).catch((error) => error);
};

async function init() {
    await getServerConfig();
    new Vue({
        router,
        store,
        render: (h) => h(App)
    }).$mount('#app');
}
init();